<!DOCTYPE html>
<html ng-app='mysecapp'>
	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="../css/reset.css" />
		<link rel="stylesheet" type="text/css" href="../css/t-login.css" />
		<link rel="stylesheet" type="text/css" href="../css/nava.css"/>
		<link rel="stylesheet" type="text/css" href="../css/foot.css" />
		<script type="text/javascript" src="../js/angular.min.js"></script>
		<script type="text/javascript" src="../js/angular-route.min.js"></script>
		<script type="text/javascript" src="../js/jquery-2.2.4.min.js"></script>
	</head>
	<body>
		<div ng-include="'nava.html'"></div>
		<!--头-->
		<div class="logo-out">
			<div>
				<img src="../img/t-logo.png" />
				<p>会员登录</p>
			</div>
		</div>
		<!--背景登录-->
		<div class="bg-content">
			<div class="login-div clearfix">
				<!--免费注册-->
				<div class="border-out">
					<div>
						<p>礼拜五会员</p>
						<p>免费注册</p>
					</div>
				</div>
				<div class="load-right">
					<div class="doad-div clearfix">
						<span>登录</span>
						<a href="t-phoneload.html">手机验证登陆 <img src="../img/icon-iPhone.png" alt="" /></a>
					</div>
					<div class="load-ph">
						<input type="text" id="t-loadtext" placeholder="请输入手机号" />
						<img class="t-loadimg" src="../img/t-phone-true.png" alt="" />
						<div class="load-wrong">
							<img src="../img/t-wrong-phone.png" alt="" />
							<span>手机号码不正确，请重新输入</span>
						</div>
					</div>
					<input type="password" id="loadpasw" placeholder="密码" />
					<div class="yanzheng"><input type="text" class="inputnum1" placeholder="验证码" />
						<div class="yanimg"></div><span class="spanbtn">看不清换一张</span></div>
					<div class="checkDiv">
						<input type="checkbox" id="loadcheck" value="" checked="false" />
						<span class="animation">&nbsp;自动登录</span>
						<a href="t-resetpasword.html">忘记密码?</a>
					</div>
					<div class="lo-div clearfix">
						<span class="loadbtn1">登录</span>
						<span class="loadbtn2">用户注册</span>
					</div>
					<span class="t-notice">提示：未注册用户将直接注册为礼拜五用户</span>
					<p><span>---------------</span>用合作网站登录<span>---------------</span></p>
					<a href="###"><img src="../img/t-load-weixin.png" alt="" /></a>
					<a href="###"><img src="../img/t-load-QQ.png" alt="" /></a>
				</div>

			</div>
		</div>
		<div class="abc"></div>
		<div ng-include="'foot.html'"></div>
	</body>
	<script type="text/javascript">
		var app = angular.module('mysecapp', ['ngRoute']);
		var bubu = false;
		
		
		
		
		app.controller('navctrl',function($scope){
			$('.pleaselogin').html(localStorage.getItem("name"));
			//我的订单
			$('.ding1').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/buy';
				}else{
					window.location='t-loadimg.html';
				};
				
			});
			//我的消息
			$('.ding2').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/msg';
				}else{
					window.location='t-loadimg.html';
				};
				
			});	
			//我的商家
			$('.ding3').click(function(){
				if (bubu) {
					window.location='personalcenter.html#/store';
				}else{
					window.location='t-loadimg.html';
				};
				
			});
						
			$('.t-tui').click(function(){
				if (bubu){
					$('.pleaselogin').html('');
					$(this).html('请登录');
					bubu = false;
					
				}else{
					$(this).html('退出');
					window.location='t-loadimg.html';
					localStorage.clear()
					bubu = true;
				}	
			})
			
			
			function getLocation() {
				if(navigator.geolocation) {
					navigator.geolocation.getCurrentPosition(showPosition, showError);
				} else {
					alert("浏览器不支持地理定位。");
				}
			}

			function showPosition(position) {
				var latlon = position.coords.latitude + ',' + position.coords.longitude;
				//baidu
				var url = "http://api.map.baidu.com/geocoder/v2/?ak=C93b5178d7a8ebdb830b9b557abce78b&callback=renderReverse&location=" + latlon + "&output=json&pois=0";
				$.ajax({
					type: "GET",
					dataType: "jsonp",
					url: url,
					beforeSend: function() {
						$("#baidu_geo").html('正在定位...');
					},
					success: function(json) {
						if(json.status == 0) {
							var add = json.result.formatted_address;
							var addre = add.substr(3, 3);
							$("#baidu_geo").html(addre);
						}
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
						$("#baidu_geo").html(latlon + "地址位置获取失败");
					}
				});
				

			}
			
			function showError(error) {
				switch(error.code) {
					case error.PERMISSION_DENIED:
						alert("定位失败,用户拒绝请求地理定位");
						break;
					case error.POSITION_UNAVAILABLE:
						alert("定位失败,位置信息是不可用");
						break;
					case error.TIMEOUT:
						alert("定位失败,请求获取用户位置超时");
						break;
					case error.UNKNOWN_ERROR:
						alert("定位失败,定位系统失效");
						break;
				}
			}

			getLocation();
	
		});
		
		
		
		
		var yanimg = document.getElementsByClassName('yanimg');

		var arr = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
			'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
			'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
		var arr1 = []
		var donum;
		var deg;
		var arr2 = [];
		var a = '';
		var b = '';
		
		var phone = document.getElementById('t-loadtext');
		$('#loadcheck').change(function() {
			if($('#loadcheck').is(":checked")) {
				$('#t-loadtext').val(localStorage.getItem("name"));
				$('#loadpasw').val(localStorage.getItem("pss"));
			}else{
				$('#t-loadtext').val('');
				$('#loadpasw').val('');
			}
		})
		//验证码
		for(var i = 0; i < 4; i++) {
			deg = Math.floor(Math.random() * 100 - 40);
			donum = Math.floor(Math.random() * 62);
			arr1.push(arr[donum])
			yanimg[0].innerHTML += "<span>" + arr1[i] + "</span>"
			$('.yanimg span').eq(i).css({
				transform: 'rotateZ(' + deg + 'deg)'
			})
			a += arr1[i]
		}
		arr1 = [];
		$('.spanbtn').click(function() {
				a = '';
				$('.yanimg').children('span').remove()
				for(var i = 0; i < 4; i++) {
					deg = Math.floor(Math.random() * 100 - 40);
					donum = Math.floor(Math.random() * 62);
					arr1.push(arr[donum])
					yanimg[0].innerHTML += "<span>" + arr1[i] + "</span>";
					$('.yanimg span').eq(i).css({
						transform: 'rotateZ(' + deg + 'deg)'
					})
					a += arr1[i]
				}
				console.log(a)
				arr1 = [];
			})
			//手机号输入内容变化函数
		phone.oninput = function() {
			$('.load-wrong').css({
				display: 'none'
			})
			if(/^1[34578]\d{9}$/.test($('#t-loadtext').val())) {
				$('.t-loadimg').css({
					display: 'block'
				})
			} else {
				$('.t-loadimg').css({
					display: 'none'
				});
			}
		}

		$('.loadbtn1').click(function() {
				
			if(!(/^1[34578]\d{9}$/.test($('#t-loadtext').val()))) {
				$('.load-wrong').css({
					display: 'block'
				})
				return false;

			}else if( $('#loadpasw').val()==''){
				alert('密码不能为空');
				return false;
			}else{
				var obj = {};
				var phone = $.trim($('#t-loadtext').val()) ;
				var psw = $.trim($('#loadpasw').val());
				
				obj.phone = phone;
				obj.psw = psw;
				$.post('../php/data2.php', obj, function(data) {
//					alert(data)
					var josn = JSON.parse(data);
					if(josn[0].pas == psw) {

						if($('.inputnum1').val() != a) {
							alert('验证码输入错误');
							return false;
						}else{
							$('.t-tui').html('退出');
							localStorage.setItem('name',phone);
							localStorage.setItem('pss',psw);
							bubu = true;
							
							
							$('.pleaselogin').html(localStorage.getItem("name"));
							$('#t-loadtext').val('');
							$('#loadpasw').val('');
							$('.inputnum1').val('');
							$('.t-loadimg').css({
								display: 'none'
							})
							
						}
				
					}else if (data=='a') {
						alert('密码错误')
					}else if (data=='b') {
						alert('此账号未被注册')
					}
				})
			}
		})
		$('.loadbtn2').click(function(){
			window.location.href = 't-login.html'
		})


	$('.logo-out div img').click(function(){
		window.location.href='index.html';
	})
	
	</script>

</html>